package com.jz.community.basecomm.mvp;

import android.content.Context;

import com.trello.rxlifecycle2.LifecycleProvider;

/**
 * Created by Tony on 2017/9/20.
 */
public class BaseLifeCyclePresent<T extends MVPContract.View> extends BaseMvpPresenter<T> implements MVPContract.Presenter<T> {

    protected Context mContext;

    @Override
    public void setPresenter(T v) {
        mContext = v.getContext();
    }

    /**
     * 对 ACTIVITY 生命周期进行管理
     *
     * @return
     */
    protected LifecycleProvider getActivityLifecycleProvider() {
        LifecycleProvider provider = null;
        if (null != mContext &&
                mContext instanceof LifecycleProvider) {
            provider = (LifecycleProvider) mContext;
        }
        return provider;
    }

    public void doDestroy() {
        this.mContext = null;
    }

}
